package com.hit.aircraftwar.difficulty;

import com.hit.aircraftwar.aircraft.AbstractAircraft;
import com.hit.aircraftwar.setter.ParameterSet;

/**
 * @author LiuYuZhe
 */
public abstract class DifficultyClass {
    private double preIndex = 1;
    double updateEnemyAttributes(int time) {
        ParameterSet.getInstance().updateSpeed(time);
        return ParameterSet.getInstance().updateEnemyAttributes(time);
    }

    int updateCycleDuration(int time) {
        return ParameterSet.getInstance().updateCycleDuration(time);
    }

    abstract AbstractAircraft creatEnemy(int enemySize, int timeWithoutElite, int score);

    public final AbstractAircraft runDifficultySystem(int time, int enemySize, int timeWithoutElite, int score) {
        int cycleDuration = updateCycleDuration(time);
        double index = updateEnemyAttributes(time);
        if(ParameterSet.getInstance().getDifficulty() != 0 && (int)(preIndex * 10) != (int)(index * 10)) {
            System.out.printf("难度播报：子弹周期现为%dms, 速度和敌机属性已达%.1f倍！\n",cycleDuration,index);
        }
        preIndex = index;
        return creatEnemy(enemySize, timeWithoutElite, score);
    }
}
